<template>
	<view class="custom_login">
		<view class="custom_login_content">
			<view class="custom_login_content_noreg" v-if="!isReg">
				<view class="custom_login_content_noreg_sms" v-if="loginType === 'sms'">
					<view class="custom_login_content_noreg_sms_title">{{ i18n('短信验证码登录') }}</view>
					<view class="custom_login_content_noreg_sms_content">
						<view class="custom_login_content_noreg_sms_content_item">
							<view class="custom_login_content_noreg_sms_content_item_input telphone">
								<view class="telphone_tip">+86</view>
								<view class="telphone_input"><input :placeholder="i18n('手机号码')" type="number" maxlength="11" v-model="smsLogin.telphone" /></view>
							</view>
							<view class="error_tips" v-if="error.telphone.Is">
								<view class="iconfont icon-error"></view>
								{{ error.telphone.message }}
							</view>
							<view class="custom_login_content_noreg_sms_content_item_input verifica_code">
								<view class="verifica_code_input">
									<input :placeholder="i18n('请输入短信验证码')" type="number" v-model="smsLogin.verificatCode" maxlength="6" />
								</view>
								<view class="verifica_code_button" v-if="!smsLogin.isCountDown">
									<view class="verifica_code_button_content" @click="getVICodeClickHandle">{{ i18n('获取验证码') }}</view>
								</view>
								<view class="verifica_code_button" v-else>
									<uni-countdown :showDay="false" :hour="0" :minute="3" :second="0" @timeup="timeupChangeHandle"></uni-countdown>
								</view>
							</view>
							<view class="error_tips" v-if="error.countDown.Is">
								<view class="iconfont icon-error"></view>
								{{ error.countDown.message }}
							</view>
							<view class="error_tips" v-if="error.verificatCode.Is">
								<view class="iconfont icon-error"></view>
								{{ error.verificatCode.message }}
							</view>
						</view>
						<!-- <view class="custom_login_content_noreg_sms_content_item tips">
							注册即代表您同意
							<view class="login_ip" @click="tipsClickHandle">{{ i18n('相关服务条款和隐私政策') }}</view>
						</view> -->
						<view class="custom_login_content_noreg_sms_content_item">
							<view class="submit_button" @click="submitSMSClickHandle">{{ i18n('登录') }}</view>
							<view class="cancle_button" @click="cancleClickHandle">{{ i18n('取消') }}</view>
						</view>
						<custom-divider>
							<template #text>
								{{ i18n('其他操作') }}
							</template>
						</custom-divider>
						<view class="custom_login_content_noreg_sms_content_item aside">
							<!-- <view class="login_toggle" @click="toggleLoginWeixinClickHandle">{{ i18n('微信登录') }}</view> -->
							<!-- <view class="login_line">|</view> -->
							<view class="login_toggle" @click="toggleLoginACCOUNTClickHandle">{{ i18n('账户密码登录') }}</view>
							<!-- <view class="login_line">|</view> -->
							<view class="login_toggle" @click="toggleRegClickHandle">{{ i18n('用户注册') }}</view>
						</view>
					</view>
				</view>
				<view class="custom_login_content_noreg_password" v-if="loginType === 'password'">
					<view class="custom_login_content_noreg_password_title">{{ i18n('账户密码登录') }}</view>
					<view class="custom_login_content_noreg_password_content">
						<view class="custom_login_content_noreg_password_content_item">
							<view class="custom_login_content_noreg_password_content_item_input telphone">
								<view class="telphone_tip">+86</view>
								<view class="telphone_input"><input :placeholder="i18n('手机号码')" maxlength="11" v-model="passwordLogin.account" /></view>
							</view>
							<view class="error_tips" v-if="error.account.Is">
								<view class="iconfont icon-error"></view>
								{{ error.account.message }}
							</view>
							<view class="custom_login_content_noreg_password_content_item_input verifica_code">
								<view class="verifica_code_input">
									<input
										:placeholder="i18n('请输入密码')"
										:type="passwordLogin.isPasswordShow ? 'text' : 'password'"
										v-model="passwordLogin.password"
										maxlength="8"
									/>
								</view>
								<view class="verifica_code_button iconfont">
									<view
										class="verifica_code_button_content toggle_show"
										:class="passwordLogin.isPasswordShow ? 'icon-browse' : 'icon-hide'"
										@click="togglePasswordShow"
									></view>
								</view>
							</view>
							<view class="error_tips" v-if="error.password.Is">
								<view class="iconfont icon-error"></view>
								{{ error.password.message }}
							</view>
							<!-- <view class="custom_login_content_noreg_password_content_item_input verifica_code">
								<view class="verifica_code_input"><input :placeholder="i18n('请输入验证码')" v-model="passwordLogin.imageVerificatCode" maxlength="8" /></view>
								<view class="verifica_code_button imgverifica">
									<image :src="'http://image.bubuko.com/info/201801/20180127102045474916.png?t=' + random" lazy-load="true" :style="{ height: '60rpx' }"></image>
									<view class="verifica_code_button_content iconfont icon-refresh" @click="getNewVerificatCodeClickHandle"></view>
								</view>
							</view> -->
							<!-- <view class="error_tips" v-if="error.imageVerificatCode.Is">
								<view class="iconfont icon-error"></view>
								{{ error.imageVerificatCode.message }}
							</view> -->
							<view class="custom_login_content_noreg_password_content_item_input verifica_code">
								<view class="verifica_code_input">
									<input :placeholder="i18n('请输入短信验证码')" type="number" v-model="passwordLogin.verificatCode" maxlength="6" />
								</view>
								<view class="verifica_code_button" v-if="!passwordLogin.isCountDown">
									<view class="verifica_code_button_content button" @click="getPasswordVICodeClickHandle">{{ i18n('获取验证码') }}</view>
								</view>
								<view class="verifica_code_button" v-else>
									<uni-countdown :showDay="false" :hour="0" :minute="3" :second="0" @timeup="passwordTimeupChangeHandle"></uni-countdown>
								</view>
							</view>
							<view class="error_tips" v-if="error.countDown.Is">
								<view class="iconfont icon-error"></view>
								{{ error.countDown.message }}
							</view>
							<view class="error_tips" v-if="error.verificatCode.Is">
								<view class="iconfont icon-error"></view>
								{{ error.verificatCode.message }}
							</view>
						</view>
						<!-- <view class="custom_login_content_noreg_password_content_item tips">
							注册即代表您同意
							<view class="login_ip" @click="tipsClickHandle">{{ i18n('相关服务条款和隐私政策') }}</view>
						</view> -->
						<view class="custom_login_content_noreg_password_content_item">
							<view class="submit_button" @click="submitACCOUNTClickHandle">{{ i18n('登录') }}</view>
							<view class="cancle_button" @click="cancleClickHandle">{{ i18n('取消') }}</view>
						</view>
						<custom-divider>
							<template #text>
								{{ i18n('其他操作') }}
							</template>
						</custom-divider>
						<view class="custom_login_content_noreg_password_content_item aside">
							<view class="login_toggle" @click="forgotPasswordClickHandle">{{ i18n('忘记密码') }}</view>
							<!-- <view class="login_line">|</view> -->
							<!-- <view class="login_toggle" @click="toggleLoginWeixinClickHandle">{{ i18n('微信登录') }}</view> -->
							<!-- <view class="login_line">|</view> -->
							<view class="login_toggle" @click="toggleLoginSMSClickHandle">{{ i18n('短信登录') }}</view>
							<!-- <view class="login_line">|</view> -->
							<view class="login_toggle" @click="toggleRegClickHandle">{{ i18n('用户注册') }}</view>
						</view>
					</view>
				</view>
				<view class="custom_login_content_noreg_wechat" v-if="loginType === 'wechat'">
					<view class="content">
						<view>{{ i18n('申请获取以下权限') }}</view>
						<text>{{ i18n('获得你的公开信息(昵称，头像等)') }}</text>
					</view>
					<button class="bottom" type="primary" lang="zh_CN" open-type="getUserInfo" @getuserinfo="bindGetUserInfo">授权登录</button>
					<view class="cancle_button" @click="cancleClickHandle">{{ i18n('取消') }}</view>
					<view class="custom_login_content_noreg_wechat_content">
						<custom-divider>
							<template #text>
								{{ i18n('其他操作') }}
							</template>
						</custom-divider>
						<view class="custom_login_content_noreg_wechat_content_item aside">
							<view class="login_toggle" @click="toggleLoginSMSClickHandle">{{ i18n('短信登录') }}</view>
							<!-- <view class="login_line">|</view> -->
							<view class="login_toggle" @click="toggleLoginACCOUNTClickHandle">{{ i18n('账户密码登录') }}</view>
							<!-- <view class="login_line">|</view> -->
							<view class="login_toggle" @click="toggleRegClickHandle">{{ i18n('用户注册') }}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="custom_login_content_reg" v-if="isReg">
				<view class="custom_login_content_reg_title">{{ i18n('用户注册') }}</view>
				<view class="custom_login_content_reg_content">
					<view class="custom_login_content_reg_content_item">
						<view class="custom_login_content_reg_content_item_input telphone">
							<view class="telphone_tip">+86</view>
							<view class="telphone_input"><input :placeholder="i18n('手机号码')" maxlength="11" v-model="reg.account" /></view>
						</view>
						<view class="error_tips" v-if="error.account.Is">
							<view class="iconfont icon-error"></view>
							{{ error.account.message }}
						</view>
						<view class="custom_login_content_reg_content_item_input verifica_code">
							<view class="verifica_code_input">
								<input :placeholder="i18n('请输入密码')" :type="reg.isPasswordShow ? 'text' : 'password'" v-model="reg.password" maxlength="8" />
							</view>
							<view class="verifica_code_button iconfont">
								<view
									class="verifica_code_button_content toggle_show"
									:class="reg.isPasswordShow ? 'icon-browse' : 'icon-hide'"
									@click="toggleRegPasswordShow"
								></view>
							</view>
						</view>
						<view class="error_tips" v-if="error.password.Is">
							<view class="iconfont icon-error"></view>
							{{ error.password.message }}
						</view>
						<view class="custom_login_content_reg_content_item_input verifica_code">
							<view class="verifica_code_input"><input :placeholder="i18n('请再次输入密码')" type="password" v-model="reg.repassword" maxlength="8" /></view>
							<view class="verifica_code_button"></view>
						</view>
						<view class="error_tips" v-if="error.repassword.Is">
							<view class="iconfont icon-error"></view>
							{{ error.repassword.message }}
						</view>
						<view class="custom_login_content_reg_content_item_input verifica_code">
							<view class="verifica_code_input"><input :placeholder="i18n('请输入短信验证码')" type="number" v-model="reg.verificatCode" maxlength="6" /></view>
							<view class="verifica_code_button" v-if="!reg.isCountDown">
								<view class="verifica_code_button_content button" @click="getRegVICodeClickHandle">{{ i18n('获取验证码') }}</view>
							</view>
							<view class="verifica_code_button" v-else>
								<uni-countdown :showDay="false" :hour="0" :minute="3" :second="0" @timeup="regTimeupChangeHandle"></uni-countdown>
							</view>
						</view>
						<view class="error_tips" v-if="error.countDown.Is">
							<view class="iconfont icon-error"></view>
							{{ error.countDown.message }}
						</view>
						<view class="error_tips" v-if="error.verificatCode.Is">
							<view class="iconfont icon-error"></view>
							{{ error.verificatCode.message }}
						</view>
					</view>
					<view class="custom_login_content_reg_content_item tips">
						注册即代表您同意
						<view class="login_ip" @click="tipsClickHandle">{{ i18n('相关服务条款和隐私政策') }}</view>
					</view>
					<view class="custom_login_content_reg_content_item">
						<view class="submit_button" @click="submitRegACCOUNTClickHandle">{{ i18n('注册') }}</view>
						<view class="cancle_button" @click="cancleClickHandle">{{ i18n('取消') }}</view>
					</view>
					<custom-divider>
						<template #text>
							{{ i18n('其他操作') }}
						</template>
					</custom-divider>
					<view class="custom_login_content_reg_content_item aside">
						<!-- <view class="login_toggle" @click="toggleLoginWeixinClickHandle">{{ i18n('微信登录') }}</view> -->
						<!-- <view class="login_line">|</view> -->
						<view class="login_toggle" @click="toggleLoginSMSClickHandle">{{ i18n('短信登录') }}</view>
						<!-- <view class="login_line">|</view> -->
						<view class="login_toggle" @click="toggleLoginACCOUNTClickHandle">{{ i18n('账户密码登录') }}</view>
					</view>
				</view>
			</view>
		</view>
		<custom-popup :item="popup.promoteAside">
			<template #popupContent>
				<custom-bind-phone></custom-bind-phone>
			</template>
		</custom-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			popup: {
				promoteAside: {
					type: 'bottom',
					show: false,
					data: {}
				}
			},
			isLogin: false,
			isReg: false,
			loginType: 'password',
			smsLogin: {
				telphone: '',
				verificatCode: '',
				isCountDown: false,
				smsVerificatCode: ''
			},
			passwordLogin: {
				account: '',
				password: '',
				//imageVerificatCode: '',
				verificatCode: '',
				isCountDown: false,
				isPasswordShow: false,
				smsVerificatCode: ''
			},
			reg: {
				account: '',
				password: '',
				repassword: '',
				verificatCode: '',
				isCountDown: false,
				isPasswordShow: false,
				smsVerificatCode: ''
			},
			random: (Math.random(10000) + '').replace(/\./gim, ''),
			error: {
				telphone: {
					Is: false,
					message: ''
				},
				verificatCode: {
					Is: false,
					message: ''
				},
				// imageVerificatCode: {
				// 	Is: false,
				// 	message: ''
				// },
				account: {
					Is: false,
					message: ''
				},
				password: {
					Is: false,
					message: ''
				},
				repassword: {
					Is: false,
					message: ''
				},
				countDown: {
					Is: false,
					message: ''
				}
			}
		};
	},
	watch: {
		'smsLogin.isCountDown'(v) {
			v === true && (this.error.countDown.Is = false);
		},
		'passwordLogin.isCountDown'(v) {
			v === true && (this.error.countDown.Is = false);
		},
		'reg.isCountDown'(v) {
			v === true && (this.error.countDown.Is = false);
		},
		'smsLogin.telphone'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.telphone.Is = true), (this.error.telphone.message = this.i18n('手机号码') + ' ' + this.i18n('不能为空')))
				: !this._plugins.isTelphoneCode(v)
				? ((this.error.telphone.Is = true), (this.error.telphone.message = this.i18n('请输入正确的') + ' ' + this.i18n('手机号码')))
				: (this.error.telphone.Is = false);
		},
		'smsLogin.verificatCode'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.verificatCode.Is = true), (this.error.verificatCode.message = this.i18n('短信验证码') + ' ' + this.i18n('不能为空')))
				: (this.error.verificatCode.Is = false);
		},
		'passwordLogin.account'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.account.Is = true), (this.error.account.message = this.i18n('手机号码') + ' ' + this.i18n('不能为空')))
				: !this._plugins.isTelphoneCode(v)
				? ((this.error.account.Is = true), (this.error.account.message = this.i18n('请输入正确的') + ' ' + this.i18n('手机号码')))
				: (this.error.account.Is = false);
		},
		'passwordLogin.password'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.password.Is = true), (this.error.password.message = this.i18n('密码') + ' ' + this.i18n('不能为空')))
				: !this._plugins.isPassword(v)
				? (this.error.password = {
						Is: true,
						message: this.i18n('密码') + this.i18n('格式/长度不对')
				  })
				: (this.error.password.Is = false);
		},
		// 'passwordLogin.imageVerificatCode'(v) {
		// 	this._plugins.isEmpty(v)
		// 		? ((this.error.imageVerificatCode.Is = true), (this.error.imageVerificatCode.message = this.i18n('验证码') + ' ' + this.i18n('不能为空')))
		// 		: (this.error.imageVerificatCode.Is = false);
		// },
		'passwordLogin.verificatCode'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.verificatCode.Is = true), (this.error.verificatCode.message = this.i18n('短信验证码') + ' ' + this.i18n('不能为空')))
				: (this.error.verificatCode.Is = false);
		},
		'reg.account'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.account.Is = true), (this.error.account.message = this.i18n('手机号码') + ' ' + this.i18n('不能为空')))
				: !this._plugins.isTelphoneCode(v)
				? ((this.error.account.Is = true), (this.error.account.message = this.i18n('请输入正确的') + ' ' + this.i18n('手机号码')))
				: (this.error.account.Is = false);
		},
		'reg.password'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.password.Is = true), (this.error.password.message = this.i18n('密码') + ' ' + this.i18n('不能为空')))
				: !this._plugins.isPassword(v)
				? (this.error.password = {
						Is: true,
						message: this.i18n('密码') + this.i18n('格式/长度不对')
				  })
				: (this.error.password.Is = false);
		},
		'reg.repassword'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.repassword.Is = true), (this.error.repassword.message = this.i18n('密码') + ' ' + this.i18n('不能为空')))
				: !this._plugins.isPassword(v)
				? (this.error.repassword = {
						Is: true,
						message: this.i18n('密码') + this.i18n('格式/长度不对')
				  })
				: v !== this.reg.password
				? ((this.error.repassword.Is = true), (this.error.repassword.message = this.i18n('密码') + ' ' + this.i18n('不相同')))
				: (this.error.repassword.Is = false);
		},
		'reg.verificatCode'(v) {
			this._plugins.isEmpty(v)
				? ((this.error.verificatCode.Is = true), (this.error.verificatCode.message = this.i18n('短信验证码') + ' ' + this.i18n('不能为空')))
				: (this.error.verificatCode.Is = false);
		}
	},
	onLoad(options) {
		uni.hideShareMenu();
		console.log(getApp().globalData, options);
		this.isLogin = getApp().globalData.token ? true : false;
		let that = this;
		this.loginType = options.type || 'sms';
		this.isReg = options.type === 'reg' ? true : false;
		uni.setNavigationBarTitle({
			title: this.i18n(that.isReg ? '用户注册' : '用户登录')
		});
		this.$on('closePopupHandle', this.closePopupHandle);
	},
	onBackPress(e) {
		console.log(e);
		if (this.isLogin) {
			return false;
		}
		return true;
	},
	methods: {
		closePopupHandle() {
			let that = this;
			this.popup.promoteAside.show = false;
			this.$toast(this.i18n('绑定手机号码失败，建议绑定'));
			that.exitTimeout && clearTimeout(that.exitTimeout);
			that.exitTimeout = setTimeout(() => {
				uni.switchTab({
					url: '../index/index'
				});
			}, 1000);
		},
		bindGetUserInfo(e) {
			let that = this;
			this._plugins
				.login(this, e.detail.userInfo)
				.then(v => {
					console.log('bindgetuserinfo:', e.detail.userInfo, v);
					that.popup.promoteAside.show = true;
					/* uni.switchTab({
						url: '../index/index'
					}); */
				})
				.catch(v => {
					console.log(v);
				}); /* 
			if (e.detail.userInfo){
				
			}else{
				
			} */
			console.log(e);
		},
		toggleRegPasswordShow() {
			this.reg.isPasswordShow = this.reg.isPasswordShow ? false : true;
		},
		togglePasswordShow() {
			this.passwordLogin.isPasswordShow = this.passwordLogin.isPasswordShow ? false : true;
		},
		requestData(func, v) {
			return this._plugins.requstData(this, func, v);
		},
		regTimeupChangeHandle() {
			this.reg.isCountDown = false;
		},
		getRegVICodeClickHandle() {
			let that = this;
			if (this._plugins.isEmpty(this.reg.account)) {
				this.error.telphone = {
					Is: true,
					message: this.i18n('手机号码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isTelphoneCode(this.reg.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('请输入正确的') + this.i18n('手机号码')
				};
				return;
			}
			uni.showLoading({
				title: this.i18n('正在发送中') + '...',
				mask: true,
				complete() {
					that.requestData(['getRegVICodeHandle'])
						.then(v => ((that.reg.isCountDown = true), (that.reg.smsVerificatCode = v[0].data.code)))
						.catch(v => {
							that.$toast(v);
							console.log(v);
						});
				}
			});
		},
		timeupChangeHandle(v) {
			this.smsLogin.isCountDown = false;
		},
		phoneBindTimeupChangeHandle(e) {
			this.phoneBindLogin.isCountDown = false;
		},
		passwordTimeupChangeHandle(e) {
			this.passwordLogin.isCountDown = false;
		},
		i18n(v) {
			return this.$t('index')[v];
		},
		getVICodeClickHandle() {
			let that = this;
			if (this._plugins.isEmpty(this.smsLogin.telphone)) {
				this.error.telphone = {
					Is: true,
					message: this.i18n('手机号码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isTelphoneCode(this.smsLogin.telphone)) {
				this.error.telphone = {
					Is: true,
					message: this.i18n('请输入正确的') + this.i18n('手机号码')
				};
				return;
			}
			uni.showLoading({
				title: this.i18n('正在发送中') + '...',
				mask: true,
				complete() {
					that.requestData(['getSMSVICodeHandle'])
						.then(v => ((that.smsLogin.isCountDown = true), (that.smsLogin.smsVerificatCode = v[0].data.code)))
						.catch(v => {
							that.$toast(v);
							console.log(v);
						});
				}
			});
		},
		getPasswordVICodeClickHandle() {
			let that = this;
			if (this._plugins.isEmpty(this.passwordLogin.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('手机号码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isTelphoneCode(this.passwordLogin.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('请输入正确的') + this.i18n('手机号码')
				};
				return;
			}
			// } else if (this._plugins.isEmpty(this.passwordLogin.imageVerificatCode)) {
			// 	this.error.imageVerificatCode = {
			// 		Is: true,
			// 		message: this.i18n('验证码') + this.i18n('不能为空')
			// 	};
			// 	return;
			// }
			uni.showLoading({
				title: this.i18n('正在发送中') + '...',
				mask: true,
				complete() {
					that.requestData(['getAccountVICodeHandle'])
						.then(v => ((that.passwordLogin.isCountDown = true), (that.passwordLogin.smsVerificatCode = v[0].data.code)))
						.catch(v => {
							that.$toast(v);
							console.log(v);
						});
				}
			});
		},
		getNewVerificatCodeClickHandle() {
			this.random = (Math.random(10000) + '').replace(/\./gim, '');
			console.log(this.random);
		},
		submitSMSClickHandle() {
			let that = this;
			if (this._plugins.isEmpty(this.smsLogin.telphone)) {
				this.error.telphone = {
					Is: true,
					message: this.i18n('手机号码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isTelphoneCode(this.smsLogin.telphone)) {
				this.error.telphone = {
					Is: true,
					message: this.i18n('请输入正确的') + this.i18n('手机号码')
				};
				return;
			} else if (!this.smsLogin.isCountDown) {
				this.error.countDown = {
					Is: true,
					message: this.i18n('请使用') + this.i18n('短信验证码')
				};
				return;
			} else if (this._plugins.isEmpty(this.smsLogin.verificatCode)) {
				this.error.verificatCode = {
					Is: true,
					message: this.i18n('短信验证码') + this.i18n('不能为空')
				};
				return;
			} else if (this.smsLogin.verificatCode !== this.smsLogin.smsVerificatCode) {
				this.error.verificatCode = {
					Is: true,
					message: this.i18n('短信验证码') + this.i18n('错误')
				};
				return;
			}
			uni.showLoading({
				title: this.i18n('正在提交中') + '...',
				mask: true,
				complete() {
					that.requestData(
						['submitSMSLoginHandle'],
						that._plugins.extend(
							{},
							{
								telphone: that.smsLogin.telphone,
								verificatCode: that.smsLogin.verificatCode
							}
						)
					)
						.then(v => {
							that._plugins.extend(getApp().globalData, {
								token: v[0].data.token,
								userInfo: v[0].data.userInfo
							});
							uni.setStorageSync('globalData', JSON.stringify(getApp().globalData));
							that.exitTimeout && clearTimeout(that.exitTimeout);
							that.exitTimeout = setTimeout(() => {
								uni.switchTab({
									url: '../index/index'
								});
							}, 1000);
						})
						.catch(v => {
							that.$toast(v);
							console.log(v);
						});
				}
			});
		},
		submitACCOUNTClickHandle() {
			let that = this;
			if (this._plugins.isEmpty(this.passwordLogin.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('手机号码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isTelphoneCode(this.passwordLogin.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('请输入正确的') + this.i18n('手机号码')
				};
				return;
			} else if (this._plugins.isEmpty(this.passwordLogin.password)) {
				this.error.password = {
					Is: true,
					message: this.i18n('密码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isPassword(this.passwordLogin.password)) {
				this.error.password = {
					Is: true,
					message: this.i18n('密码') + this.i18n('格式/长度不对')
				};
				return;
			// } else if (this._plugins.isEmpty(this.passwordLogin.imageVerificatCode)) {
			// 	this.error.imageVerificatCode = {
			// 		Is: true,
			// 		message: this.i18n('验证码') + this.i18n('不能为空')
			// 	};
			// 	return;
			} else if (!this.passwordLogin.isCountDown) {
				this.error.countDown = {
					Is: true,
					message: this.i18n('请使用') + this.i18n('短信验证码')
				};
				return;
			} else if (this._plugins.isEmpty(this.passwordLogin.verificatCode)) {
				this.error.verificatCode = {
					Is: true,
					message: this.i18n('短信验证码') + this.i18n('不能为空')
				};
				return;
			} else if (this.passwordLogin.verificatCode !== this.passwordLogin.smsVerificatCode) {
				this.error.verificatCode = {
					Is: true,
					message: this.i18n('短信验证码') + this.i18n('错误')
				};
				return;
			}
			uni.showLoading({
				title: this.i18n('正在提交中') + '...',
				mask: true,
				complete() {
					that.requestData(
						['submitAccountLoginHandle'],
						that._plugins.extend(
							{},
							{
								account: that.passwordLogin.account,
								password: that._plugins.hexMD5(that.passwordLogin.password),
								//imageVerificatCode: that.passwordLogin.imageVerificatCode,
								verificatCode: that.passwordLogin.verificatCode
							}
						)
					)
						.then(v => {
							that._plugins.extend(getApp().globalData, {
								token: v[0].data.token,
								userInfo: v[0].data.userInfo
							});
							uni.setStorageSync('globalData', JSON.stringify(getApp().globalData));
							let currentPageLen = getCurrentPages().length;
							that.exitTimeout && clearTimeout(that.exitTimeout);
							that.exitTimeout = setTimeout(() => {
								uni.switchTab({
									url: '../index/index'
								});
							}, 1000);
						})
						.catch(v => {
							that.$toast(v);
							console.log(v);
						});
				}
			});
		},
		submitRegACCOUNTClickHandle() {
			let that = this;
			if (this._plugins.isEmpty(this.reg.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('手机号码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isTelphoneCode(this.reg.account)) {
				this.error.account = {
					Is: true,
					message: this.i18n('请输入正确的') + this.i18n('手机号码')
				};
				return;
			} else if (this._plugins.isEmpty(this.reg.password)) {
				this.error.password = {
					Is: true,
					message: this.i18n('密码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isPassword(this.reg.password)) {
				this.error.password = {
					Is: true,
					message: this.i18n('密码') + this.i18n('格式/长度不对')
				};
				return;
			} else if (this._plugins.isEmpty(this.reg.repassword)) {
				this.error.repassword = {
					Is: true,
					message: this.i18n('密码') + this.i18n('不能为空')
				};
				return;
			} else if (!this._plugins.isPassword(this.reg.repassword)) {
				this.error.repassword = {
					Is: true,
					message: this.i18n('密码') + this.i18n('格式/长度不对')
				};
				return;
			} else if (this.reg.repassword !== this.reg.password) {
				this.error.repassword = {
					Is: true,
					message: this.i18n('密码') + this.i18n('不相同')
				};
				return;
			} else if (!this.reg.isCountDown) {
				this.error.countDown = {
					Is: true,
					message: this.i18n('请使用') + this.i18n('短信验证码')
				};
				return;
			} else if (this._plugins.isEmpty(this.reg.verificatCode)) {
				this.error.verificatCode = {
					Is: true,
					message: this.i18n('短信验证码') + this.i18n('不能为空')
				};
				return;
			} else if (this.reg.verificatCode !== this.reg.smsVerificatCode) {
				this.error.verificatCode = {
					Is: true,
					message: this.i18n('短信验证码') + this.i18n('错误')
				};
				return;
			}
			uni.showLoading({
				title: this.i18n('正在提交中') + '...',
				mask: true,
				complete() {
					that.requestData(
						['submitRegAccountHandle'],
						that._plugins.extend(
							{},
							{
								account: that.reg.account,
								password: that._plugins.hexMD5(that.reg.password),
								repassword: that._plugins.hexMD5(that.reg.repassword),
								verificatCode: that.reg.verificatCode
							}
						)
					)
						.then(v => {
							that._plugins.extend(getApp().globalData, {
								token: v[0].data.token,
								userInfo: v[0].data.userInfo
							});
							uni.setStorageSync('globalData', JSON.stringify(getApp().globalData));
							that.exitTimeout && clearTimeout(that.exitTimeout);
							that.exitTimeout = setTimeout(() => {
								uni.switchTab({
									url: '../index/index'
								});
							}, 1000);
						})
						.catch(v => {
							that.$toast(v);
							console.log(v);
						});
				}
			});
		},
		toggleLoginWeixinClickHandle() {
			uni.navigateTo({
				url: '../../pages/login/login?type=wechat'
			});
		},
		toggleLoginACCOUNTClickHandle() {
			uni.navigateTo({
				url: '../../pages/login/login?type=password'
			});
		},
		toggleLoginSMSClickHandle() {
			uni.navigateTo({
				url: '../../pages/login/login?type=sms'
			});
		},
		toggleRegClickHandle() {
			uni.navigateTo({
				url: '../../pages/login/login?type=reg'
			});
		},
		cancleClickHandle() {
			uni.navigateBack({
				delta: 1
			});
		},
		tipsClickHandle() {
			uni.navigateTo({
				url: '../../pages/login/tipsList'
			});
		},
		forgotPasswordClickHandle() {
			uni.navigateTo({
				url: '../../pages/login/forgotPassword'
			});
		}
	}
};
</script>

<style lang="less">
.custom_login {
	.custom_login_content {
		font-size: 28rpx;
		.error_tips {
			color: #fb3640;
			font-size: 28rpx;
			text-align: left;
			padding: 10rpx 0;
			.iconfont {
				display: inline;
				margin: 0 10rpx 0 0;
			}
		}
		.custom_login_content_noreg {
			.custom_login_content_noreg_sms {
				.custom_login_content_noreg_sms_title {
					padding: 120rpx 0 100rpx 0;
					text-align: center;
				}
				.custom_login_content_noreg_sms_content {
					padding: 10rpx 30rpx;
					.custom_login_content_noreg_sms_content_item {
						padding: 20rpx 0;
						text-align: center;
						&.aside {
							.login_toggle {
								display: block;
								text-align: center;
								padding: 20rpx 20rpx;
								font-size: 28rpx;
								border: 2rpx #efefef solid;
								border-radius: 10rpx;
								text-decoration: none;
								color: #333333;
								width: auto;
								margin: 10rpx auto;
							}
						}
						&.tips {
							text-align: center;
							font-size: 24rpx;
							color: #999999;
							padding: 20rpx 0;
							.login_ip {
								display: inline;
								margin: 0 0 0 10rpx;
								text-decoration: underline;
								color: #000000;
							}
						}
						.submit_button {
							padding: 20rpx 20rpx;
							text-align: center;
							background-color: #f9b208;
							border-radius: 10rpx;
							margin: 10rpx auto;
						}
						.cancle_button {
							padding: 20rpx 20rpx;
							text-align: center;
							background-color: #efefef;
							border-radius: 10rpx;
							margin: 10rpx auto;
						}
						.login_toggle {
							display: inline;
							width: 200rpx;
							text-align: center;
							text-decoration: underline;
							color: #0000ff;
						}
						.login_line {
							padding: 0 10rpx;
							display: inline;
							color: #efefef;
						}
						.custom_login_content_noreg_sms_content_item_input {
							padding: 10rpx 0;
							border-bottom: 2rpx #efefef solid;
							&.telphone {
								display: flex;
								.telphone_tip {
									width: 100rpx;
									padding: 20rpx;
									text-align: right;
									border-right: 2rpx #efefef solid;
									color: #cccccc;
								}
								.telphone_input {
									flex: 1;
									input {
										padding: 10rpx;
										margin: 10rpx;
										text-align: left;
									}
								}
							}
							&.verifica_code {
								display: flex;
								.verifica_code_input {
									flex: 1;
									input {
										padding: 10rpx;
										margin: 10rpx;
										text-align: left;
									}
								}
								.verifica_code_button {
									width: 260rpx;
									.uni-countdown {
										padding: 16rpx 0 0;
									}
									.verifica_code_button_content {
										text-align: center;
										border-radius: 10rpx;
										background-color: #f9b208;
										padding: 10rpx 20rpx;
										margin: 10rpx;
									}
								}
							}
						}
					}
				}
			}
			.custom_login_content_noreg_password {
				.custom_login_content_noreg_password_title {
					padding: 120rpx 0 100rpx 0;
					text-align: center;
				}
				.custom_login_content_noreg_password_content {
					padding: 10rpx 30rpx;
					.custom_login_content_noreg_password_content_item {
						padding: 20rpx 0;
						text-align: center;
						&.aside {
							.login_toggle {
								display: block;
								text-align: center;
								padding: 20rpx 20rpx;
								font-size: 28rpx;
								border: 2rpx #efefef solid;
								border-radius: 10rpx;
								text-decoration: none;
								color: #333333;
								width: auto;
								margin: 10rpx auto;
							}
						}
						&.tips {
							text-align: center;
							font-size: 24rpx;
							color: #999999;
							padding: 20rpx 0;
							.login_ip {
								display: inline;
								margin: 0 0 0 10rpx;
								text-decoration: underline;
								color: #000000;
							}
						}
						.submit_button {
							padding: 20rpx 20rpx;
							text-align: center;
							background-color: #f9b208;
							border-radius: 10rpx;
							margin: 10rpx auto;
						}
						.cancle_button {
							padding: 20rpx 20rpx;
							text-align: center;
							background-color: #efefef;
							border-radius: 10rpx;
							margin: 10rpx auto;
						}
						.login_toggle {
							display: inline;
							width: 200rpx;
							text-align: center;
							text-decoration: underline;
							color: #0000ff;
						}
						.login_line {
							padding: 0 10rpx;
							display: inline;
							color: #efefef;
						}
						.custom_login_content_noreg_password_content_item_input {
							padding: 10rpx 0;
							border-bottom: 2rpx #efefef solid;
							&.telphone {
								display: flex;
								.telphone_tip {
									width: 100rpx;
									padding: 20rpx;
									text-align: right;
									border-right: 2rpx #efefef solid;
									color: #cccccc;
								}
								.telphone_input {
									flex: 1;
									input {
										padding: 10rpx;
										margin: 10rpx;
										text-align: left;
									}
								}
							}
							&.verifica_code {
								display: flex;
								.verifica_code_input {
									flex: 1;
									input {
										padding: 10rpx;
										margin: 10rpx;
										text-align: left;
									}
								}
								.verifica_code_button {
									width: 260rpx;
									&.imgverifica {
										display: flex;
										image {
											height: 30px;
											background-color: #ccc;
											margin: 12rpx 15rpx 0 0;
										}
									}
									&.iconfont {
										width: 100rpx;
										.toggle_show {
											font-size: 42rpx;
										}
									}
									.uni-countdown {
										padding: 16rpx 0 0;
									}
									.verifica_code_button_content {
										text-align: center;
										color: #999999;
										line-height: 65rpx;
										padding: 10rpx;
										&.button {
											text-align: center;
											border-radius: 10rpx;
											background-color: #f9b208;
											padding: 10rpx 20rpx;
											margin: 10rpx;
											color: #333333;
											line-height: normal;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		.custom_login_content_noreg_wechat {
			font-size: 28rpx;
			.content {
				padding: 200rpx 0;
				margin: 0 120rpx;
			}
			button {
				font-size: 28rpx;
				&.bottom {
					margin: 0 30rpx;
				}
			}

			.cancle_button {
				padding: 20rpx 20rpx;
				text-align: center;
				background-color: #efefef;
				border-radius: 10rpx;
				margin: 10rpx 30rpx;
			}
			.custom_login_content_noreg_wechat_content {
				padding: 10rpx 30rpx;
				.custom_login_content_noreg_wechat_content_item {
					padding: 20rpx 0;
					text-align: center;
					&.aside {
						.login_toggle {
							display: block;
							text-align: center;
							padding: 20rpx 20rpx;
							font-size: 28rpx;
							border: 2rpx #efefef solid;
							border-radius: 10rpx;
							text-decoration: none;
							color: #333333;
							width: auto;
							margin: 10rpx auto;
						}
					}
				}
			}
		}
		.custom_login_content_reg {
			.custom_login_content_reg_title {
				padding: 120rpx 0 100rpx 0;
				text-align: center;
			}
			.custom_login_content_reg_content {
				padding: 10rpx 30rpx;
				.custom_login_content_reg_content_item {
					padding: 20rpx 0;
					text-align: center;
					&.aside {
						.login_toggle {
							display: block;
							text-align: center;
							padding: 20rpx 20rpx;
							font-size: 28rpx;
							border: 2rpx #efefef solid;
							border-radius: 10rpx;
							text-decoration: none;
							color: #333333;
							width: auto;
							margin: 10rpx auto;
						}
					}
					&.tips {
						text-align: center;
						font-size: 24rpx;
						color: #999999;
						padding: 20rpx 0;
						.login_ip {
							display: inline;
							margin: 0 0 0 10rpx;
							text-decoration: underline;
							color: #000000;
						}
					}
					.submit_button {
						padding: 20rpx 20rpx;
						text-align: center;
						background-color: #f9b208;
						border-radius: 10rpx;
						margin: 10rpx auto;
					}
					.cancle_button {
						padding: 20rpx 20rpx;
						text-align: center;
						background-color: #efefef;
						border-radius: 10rpx;
						margin: 10rpx auto;
					}
					.login_toggle {
						display: inline;
						width: 200rpx;
						text-align: center;
						text-decoration: underline;
						color: #0000ff;
					}
					.login_line {
						padding: 0 10rpx;
						display: inline;
						color: #efefef;
					}
					.custom_login_content_reg_content_item_input {
						padding: 10rpx 0;
						border-bottom: 2rpx #efefef solid;
						&.telphone {
							display: flex;
							.telphone_tip {
								width: 100rpx;
								padding: 20rpx;
								text-align: right;
								border-right: 2rpx #efefef solid;
								color: #cccccc;
							}
							.telphone_input {
								flex: 1;
								input {
									padding: 10rpx;
									margin: 10rpx;
									text-align: left;
								}
							}
						}
						&.verifica_code {
							display: flex;
							.verifica_code_input {
								flex: 1;
								input {
									padding: 10rpx;
									margin: 10rpx;
									text-align: left;
								}
							}
							.verifica_code_button {
								width: 260rpx;
								&.imgverifica {
									display: flex;
									image {
										height: 30px;
										background-color: #ccc;
										margin: 12rpx 15rpx 0 0;
									}
								}
								&.iconfont {
									width: 100rpx;
									.toggle_show {
										font-size: 42rpx;
									}
								}
								.uni-countdown {
									padding: 16rpx 0 0;
								}
								.verifica_code_button_content {
									text-align: center;
									color: #999999;
									line-height: 65rpx;
									padding: 10rpx;
									&.button {
										text-align: center;
										border-radius: 10rpx;
										background-color: #f9b208;
										padding: 10rpx 20rpx;
										margin: 10rpx;
										color: #333333;
										line-height: normal;
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
</style>
